package com.monboo.album.view.component.mask
{
	import com.monboo.album.common.AlbumConst;
	import com.monboo.album.view.AlbumInfoMediator;
	import com.monboo.album.view.component.AbstractChangeUI;
	
	import flash.display.MovieClip;
	import flash.display.Sprite;

	public class TransitionMask extends AbstractChangeUI
	{
		private var numArr:Array = new Array();
		private var trans:MovieClip;
		private var transContent:Sprite;
		public var transScale:Number = 2;
		
		private var tranSwf:Object;
		private var playerWidth:Number;
		private var playerHeight:Number;
		private var imageInfo:AlbumInfoMediator;
		
		public function TransitionMask(arr:Array,_tranSwf:Object,_imageInfo:AlbumInfoMediator)
		{
			super(_imageInfo);
			imageInfo = _imageInfo;
			numArr =arr;
			tranSwf = _tranSwf;
			init();
		}
		private function init():void{
			transContent = new Sprite();
			addChild(transContent);
			transContent.name = "transContent";
			
			playerWidth = imageInfo.imageWidth;
			playerHeight = imageInfo.imageHeight;	
			
			getTrans(0);
			
			changeSize(transContent);
		}
		
		public function getTrans(n:Number):void{
			
			while(transContent.numChildren){
				transContent.removeChildAt(0);
			}
			
			if(numArr[n]){
				trans = tranSwf.getTransition(numArr[n]);	
			}else{
				trans = makeArea(playerWidth,playerHeight);
			}		
			transContent.addChild(trans);	
		}
		
		private function makeArea(w:uint,h:uint,alpha:Number= 1):MovieClip {	
			var area:MovieClip = new MovieClip();
			area.alpha=alpha;
			area.graphics.beginFill(0x000000,1);
			area.graphics.drawRect(0,0,w,h);
			area.graphics.endFill();
			return area;		
		}
	}
}